import { adminBaseRoutePath } from '/@/router/static/adminBase'
import createAxios from '/@/utils/axios'

const deliveryUrl = adminBaseRoutePath + '/shop.delivery.company/'
const orderUrl = adminBaseRoutePath + '/shop.order.order/'
const refundOrderUrl = adminBaseRoutePath + '/shop.order.refund/'
const orderDeliveryUrl = adminBaseRoutePath + '/shop.order.delivery/'

//快递公司
export function getDeliveryCompany() {
    return createAxios({
        url: deliveryUrl + 'company',
        method: 'get',
    })
}

//订单发货
export function delivery(params: anyObj) {
    return createAxios(
        {
            url: orderDeliveryUrl + 'delivery',
            method: 'post',
            data: params,
        },
        {
            showSuccessMessage: true,
        }
    )
}

//物流轨迹
export function getExpressTrack(params: anyObj) {
    return createAxios(
        {
            url: orderDeliveryUrl + 'expressTrack',
            method: 'get',
            params,
        },
        {
            loading: true,
        }
    )
}

//订单状态日志
export function getStatusLog(orderId: number) {
    return createAxios({
        url: orderUrl + 'statusLog',
        method: 'get',
        params: {
            id: orderId,
        },
    })
}

//订单状态信息
export function getStatusInfo() {
    return createAxios({
        url: orderUrl + 'statusInfo',
        method: 'get',
    })
}

//退款订单状态信息
export function getRefundStatusInfo() {
    return createAxios({
        url: refundOrderUrl + 'statusInfo',
        method: 'get',
    })
}

export function getPayWayTab() {
    return createAxios({
        url: orderUrl + 'payWayTab',
        method: 'get',
    })
}

// 取消审核
export function cancelOrder(params: anyObj) {
    return createAxios(
        {
            url: orderUrl + 'cancel',
            method: 'post',
            data: params,
        },
        {
            loading: true,
            showSuccessMessage: true,
        }
    )
}

// 创建导出任务
export const createExportTask = (params: anyObj) => {
    return createAxios(
        {
            url: orderUrl + 'addExportTask',
            method: 'get',
            params,
        },
        {
            loading: true,
            showSuccessMessage: true,
        }
    )
}

export const closeOrder = (params: anyObj) => {
    return createAxios(
        {
            url: orderUrl + 'close',
            method: 'post',
            data: params,
        },
        {
            loading: true,
            showSuccessMessage: true,
        }
    )
}
